/*
 * IpdDump_NewGUI.java
 * @author Jimmys Daskalakis - jimdaskalakis01@gmail.com
 * Created on 10 Ιουν 2009, 11:50:15 πμ
 */
package gui;
import java.awt.Component;

import javax.swing.JTable;
import ipddump.tools.writers.*;
import ipddump.data.Records.*;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.StringSelection;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.table.TableModel;
import ipddump.*;
import ipddump.data.*;
import ipddump.tools.*;
import java.text.BreakIterator;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author Jimmys Daskalakis - jimdaskalakis01@gmail.com
 */
public class IpdDump_NewGUI extends javax.swing.JFrame {
    private boolean letgo=false;
    private String ext;
    private String fileToSave;
    private InteractivePagerBackup database;
    private HistoryMaker historyMaker;
    IPDParser parser;
    private final int SMStabINDEX;
    private final int ContactstabINDEX;
    private final int CalendartabINDEX;
    private final int CallLogstabINDEX;
    private final int TaskstabINDEX;
    private final int OptionstabINDEX;
    private final int MemostabINDEX;
    private int ActiveTAB;
    private int totalSMS = 0;
    private int[] SMSSelectedRows;
    private int totalContacts = 0;
    private int[] ContactsSelectedRows;
    private int totalCalendar = 0;
    private int[] CalendarSelectedRows;
    private int totalCallLogs = 0;
    private int[] CallLogsSelectedRows;
    private int totalMemos = 0;
    private int[] MemosSelectedRows;
    private int totalTasks = 0;
    private int[] TasksSelectedRows;
    private final int totalOptions = 0;
    private int[] OptionsSelectedRows;
    private final DataViewer viewer;
    private final FileWriters fileWriter = new FileWriters();
    private Finder finder;
    private SmsWriters SMS;
    private ContactsWriters Contacts;
    private MemosWriters Memos;
    private TasksWriters Tasks;
    private CallLogsWriters CallLogs;
    private TableModel ContactsDataModel;
    private TableModel MemosDataModel;
    private TableModel TasksDataModel;
    private TableModel SMSDataModel;
    private TableModel CallLogsDataModel;
    private final int SMSWasSentIndex = 0;
    private final int SMSNumberIndex = 1;
    private final int SMSTextIndex = 2;
    private final int SMSSentIndex = 3;
    private final int SMSReceivedIndex = 4;
    private final int ContactsNameIndex = 0;
    private final int ContactsEmailIndex = 1;
    private final int ContactsMobileIndex = 2;
    private final int ContactsWorkIndex = 3;
    private final int ContactsHomeNumberIndex = 4;
    private final int ContactsNotesIndex = 5;
    private final int MemosTitleIndex = 0;
    private final int MemosMemoIndex = 1;
    private final int TaskTitleIndex = 0;
    private final int TaskStatusIndex = 1;
    private final int TaskPriorityIndex = 2;
    private final int TasksDueIndex = 3;
    private final int TasksReminderIndex = 4;
    private final int TasksNotesIndex = 5;
    private final int TasksTimeZoneIndex = 6;
    private final int CallLogsNameIndex = 0;
    private final int CallLogsDateIndex = 1;
    private final int CallLogsStatusIndex = 2;
    private final int CallLogsDurationIndex = 3;
    private boolean resolveContactsNames = true;
    private final String baseName = "gui.resources.IPDdumpAboutBox";
    private final ResourceBundle rb = ResourceBundle.getBundle(baseName, new Locale("en"));
    private final String welcomeMsg =
            rb.getString("welcomeMsg");
    private String tempWelcomeMsg = welcomeMsg;
    private String numOfSelectedRows = "";
    private int hoveredRow = -2;
    private long startTime;
//    private SMSRenderer renderer=new SMSRenderer();

    /** Creates new form IpdDump_NewGUI */
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        IpdChooser = new javax.swing.JFileChooser();
        MessageFrame = new javax.swing.JFrame();
        jFileChooser1 = new javax.swing.JFileChooser();
        jPopupMenu = new javax.swing.JPopupMenu();
        jMenuItemTxt = new javax.swing.JMenuItem();
        jMenuItemXML = new javax.swing.JMenuItem();
        jMenuItemCSV = new javax.swing.JMenuItem();
        jSeparator = new javax.swing.JSeparator();
        jMenuCP = new javax.swing.JMenu();
        jMenuItemCPTXT = new javax.swing.JMenuItem();
        jMenuItemCPXML = new javax.swing.JMenuItem();
        jMenuItemCPCSV = new javax.swing.JMenuItem();
        jMenuSpSMS = new javax.swing.JMenu();
        jMenuItemSelectedSMSTxt = new javax.swing.JMenuItem();
        jMenuItemSelectedSMSXML = new javax.swing.JMenuItem();
        jMenuItemSelectedSMSCSV = new javax.swing.JMenuItem();
        jMenuSpCallLogs = new javax.swing.JMenu();
        jMenuItemSelectedCallLogsText = new javax.swing.JMenuItem();
        jMenuItemSelectedCallLogsXML = new javax.swing.JMenuItem();
        jMenuItemSelectedCallLogsCSV = new javax.swing.JMenuItem();
        jMenuHistory = new javax.swing.JMenu();
        jMenuItemViewHistoryTXT = new javax.swing.JMenuItem();
        jMenuItemViewHistoryXML = new javax.swing.JMenuItem();
        mainTabbedPane = new javax.swing.JTabbedPane();
        jPanelSMS = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTableSMS = new javax.swing.JTable();
        jPanelContacts = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTableContacts = new javax.swing.JTable();
        jPanelMemo = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTableMemos = new javax.swing.JTable();
        jPanelTasks = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTableTasks = new javax.swing.JTable();
        jPanelCallLogs = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        jTableCallLogs = new javax.swing.JTable();
        jPanelCalendar = new javax.swing.JPanel();
        status_label7 = new javax.swing.JLabel();
        jPanelOptions = new javax.swing.JPanel();
        status_label6 = new javax.swing.JLabel();
        status_label = new javax.swing.JLabel();
        jProgressBar1 = new javax.swing.JProgressBar();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        openMenuItem = new javax.swing.JMenuItem();
        saveAsMenuItem = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JSeparator();
        exitMenuItem = new javax.swing.JMenuItem();
        jMenuSettings = new javax.swing.JMenu();
        ResolveCheckBox = new javax.swing.JCheckBoxMenuItem();
        TollTipsBoxMenuItem = new javax.swing.JCheckBoxMenuItem();
        AdrrBookAllCheckBox = new javax.swing.JCheckBoxMenuItem();
        jMenuHelp = new javax.swing.JMenu();
        jMenuItemAbout = new javax.swing.JMenuItem();

        IpdChooser.setAcceptAllFileFilterUsed(false);

        javax.swing.GroupLayout MessageFrameLayout = new javax.swing.GroupLayout(MessageFrame.getContentPane());
        MessageFrame.getContentPane().setLayout(MessageFrameLayout);
        MessageFrameLayout.setHorizontalGroup(
            MessageFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        MessageFrameLayout.setVerticalGroup(
            MessageFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        jMenuItemTxt.setText("View in PlainText");
        jMenuItemTxt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemTxtActionPerformed(evt);
            }
        });
        jPopupMenu.add(jMenuItemTxt);

        jMenuItemXML.setText("View in Xml");
        jMenuItemXML.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemXMLActionPerformed(evt);
            }
        });
        jPopupMenu.add(jMenuItemXML);

        jMenuItemCSV.setText("View in Csv");
        jMenuItemCSV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCSVActionPerformed(evt);
            }
        });
        jPopupMenu.add(jMenuItemCSV);
        jPopupMenu.add(jSeparator);

        jMenuCP.setText("Copy in-->");

        jMenuItemCPTXT.setText("Plain Text");
        jMenuItemCPTXT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCPTXTActionPerformed(evt);
            }
        });
        jMenuCP.add(jMenuItemCPTXT);

        jMenuItemCPXML.setText("XML");
        jMenuItemCPXML.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCPXMLActionPerformed(evt);
            }
        });
        jMenuCP.add(jMenuItemCPXML);

        jMenuItemCPCSV.setText("CSV");
        jMenuItemCPCSV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCPCSVActionPerformed(evt);
            }
        });
        jMenuCP.add(jMenuItemCPCSV);

        jPopupMenu.add(jMenuCP);

        jMenuSpSMS.setText("Sms's from this contact\\s");
        jMenuSpSMS.setActionCommand("Sms's from this contact/s");

        jMenuItemSelectedSMSTxt.setText("View in PlainText");
        jMenuItemSelectedSMSTxt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSelectedSMSTxtActionPerformed(evt);
            }
        });
        jMenuSpSMS.add(jMenuItemSelectedSMSTxt);

        jMenuItemSelectedSMSXML.setText("View in Xml");
        jMenuItemSelectedSMSXML.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSelectedSMSXMLActionPerformed(evt);
            }
        });
        jMenuSpSMS.add(jMenuItemSelectedSMSXML);

        jMenuItemSelectedSMSCSV.setText("View in Csv");
        jMenuItemSelectedSMSCSV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSelectedSMSCSVActionPerformed(evt);
            }
        });
        jMenuSpSMS.add(jMenuItemSelectedSMSCSV);

        jPopupMenu.add(jMenuSpSMS);

        jMenuSpCallLogs.setText("Call Logs from this contact\\s");
        jMenuSpCallLogs.setActionCommand("Sms's from this contact/s");

        jMenuItemSelectedCallLogsText.setText("View in PlainText");
        jMenuItemSelectedCallLogsText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSelectedCallLogsTextActionPerformed(evt);
            }
        });
        jMenuSpCallLogs.add(jMenuItemSelectedCallLogsText);

        jMenuItemSelectedCallLogsXML.setText("View in Xml");
        jMenuItemSelectedCallLogsXML.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSelectedCallLogsXMLActionPerformed(evt);
            }
        });
        jMenuSpCallLogs.add(jMenuItemSelectedCallLogsXML);

        jMenuItemSelectedCallLogsCSV.setText("View in Csv");
        jMenuItemSelectedCallLogsCSV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSelectedCallLogsCSVActionPerformed(evt);
            }
        });
        jMenuSpCallLogs.add(jMenuItemSelectedCallLogsCSV);

        jPopupMenu.add(jMenuSpCallLogs);

        jMenuHistory.setText("View History");

        jMenuItemViewHistoryTXT.setText("View History - TXT");
        jMenuItemViewHistoryTXT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemViewHistoryTXTActionPerformed(evt);
            }
        });
        jMenuHistory.add(jMenuItemViewHistoryTXT);

        jMenuItemViewHistoryXML.setText("View History - XML");
        jMenuItemViewHistoryXML.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemViewHistoryXMLActionPerformed(evt);
            }
        });
        jMenuHistory.add(jMenuItemViewHistoryXML);

        jPopupMenu.add(jMenuHistory);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("IPDdump");
        setMinimumSize(new java.awt.Dimension(100, 500));

        jTableSMS.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Sent?", "Number", "Text", "Sent Date", "Received Date"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableSMS.setName("SMS"); // NOI18N
        jTableSMS.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        jTableSMS.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableSMSMouseClicked(evt);
            }
        });
        jTableSMS.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                jTableSMSMouseMoved(evt);
            }
        });
        jScrollPane1.setViewportView(jTableSMS);
        jTableSMS.getColumnModel().getColumn(0).setPreferredWidth(60);
        jTableSMS.getColumnModel().getColumn(0).setMaxWidth(60);
        jTableSMS.getColumnModel().getColumn(1).setMaxWidth(150);
        jTableSMS.getColumnModel().getColumn(2).setMinWidth(150);
        jTableSMS.getColumnModel().getColumn(3).setMaxWidth(200);
        jTableSMS.getColumnModel().getColumn(4).setMaxWidth(200);

        javax.swing.GroupLayout jPanelSMSLayout = new javax.swing.GroupLayout(jPanelSMS);
        jPanelSMS.setLayout(jPanelSMSLayout);
        jPanelSMSLayout.setHorizontalGroup(
            jPanelSMSLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 741, Short.MAX_VALUE)
        );
        jPanelSMSLayout.setVerticalGroup(
            jPanelSMSLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE)
        );

        mainTabbedPane.addTab("SMS", jPanelSMS);

        jTableContacts.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Name", "Email", "Mobile", "Work", "Home", "Notes"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableContacts.setName("Contacts"); // NOI18N
        jTableContacts.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        jTableContacts.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableContactsMouseClicked(evt);
            }
        });
        jTableContacts.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                jTableContactsMouseMoved(evt);
            }
        });
        jScrollPane2.setViewportView(jTableContacts);
        jTableContacts.getColumnModel().getColumn(0).setMinWidth(100);
        jTableContacts.getColumnModel().getColumn(0).setPreferredWidth(150);
        jTableContacts.getColumnModel().getColumn(0).setMaxWidth(300);
        jTableContacts.getColumnModel().getColumn(1).setPreferredWidth(170);
        jTableContacts.getColumnModel().getColumn(1).setMaxWidth(300);
        jTableContacts.getColumnModel().getColumn(2).setMinWidth(120);
        jTableContacts.getColumnModel().getColumn(2).setPreferredWidth(120);
        jTableContacts.getColumnModel().getColumn(2).setMaxWidth(180);
        jTableContacts.getColumnModel().getColumn(3).setMinWidth(120);
        jTableContacts.getColumnModel().getColumn(3).setPreferredWidth(120);
        jTableContacts.getColumnModel().getColumn(3).setMaxWidth(180);
        jTableContacts.getColumnModel().getColumn(4).setMinWidth(120);
        jTableContacts.getColumnModel().getColumn(4).setPreferredWidth(120);
        jTableContacts.getColumnModel().getColumn(4).setMaxWidth(180);
        jTableContacts.getColumnModel().getColumn(5).setMinWidth(60);

        javax.swing.GroupLayout jPanelContactsLayout = new javax.swing.GroupLayout(jPanelContacts);
        jPanelContacts.setLayout(jPanelContactsLayout);
        jPanelContactsLayout.setHorizontalGroup(
            jPanelContactsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 741, Short.MAX_VALUE)
        );
        jPanelContactsLayout.setVerticalGroup(
            jPanelContactsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE)
        );

        mainTabbedPane.addTab("Contacts", jPanelContacts);

        jTableMemos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Title", "Memo"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableMemos.setName("Memos"); // NOI18N
        jTableMemos.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        jTableMemos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableMemosMouseClicked(evt);
            }
        });
        jTableMemos.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                jTableMemosMouseMoved(evt);
            }
        });
        jScrollPane3.setViewportView(jTableMemos);
        jTableMemos.getColumnModel().getColumn(0).setMinWidth(100);
        jTableMemos.getColumnModel().getColumn(0).setPreferredWidth(150);
        jTableMemos.getColumnModel().getColumn(0).setMaxWidth(250);
        jTableMemos.getColumnModel().getColumn(1).setPreferredWidth(500);

        javax.swing.GroupLayout jPanelMemoLayout = new javax.swing.GroupLayout(jPanelMemo);
        jPanelMemo.setLayout(jPanelMemoLayout);
        jPanelMemoLayout.setHorizontalGroup(
            jPanelMemoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 741, Short.MAX_VALUE)
        );
        jPanelMemoLayout.setVerticalGroup(
            jPanelMemoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE)
        );

        mainTabbedPane.addTab("Memos", jPanelMemo);

        jTableTasks.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Task", "Status", "Priority", "Due Date", "Reminder", "Notes", "Time Zone"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableTasks.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        jTableTasks.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableTasksMouseClicked(evt);
            }
        });
        jTableTasks.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                jTableTasksMouseMoved(evt);
            }
        });
        jScrollPane4.setViewportView(jTableTasks);
        jTableTasks.getColumnModel().getColumn(0).setMinWidth(70);
        jTableTasks.getColumnModel().getColumn(0).setPreferredWidth(100);
        jTableTasks.getColumnModel().getColumn(0).setMaxWidth(250);
        jTableTasks.getColumnModel().getColumn(1).setMinWidth(80);
        jTableTasks.getColumnModel().getColumn(1).setPreferredWidth(80);
        jTableTasks.getColumnModel().getColumn(1).setMaxWidth(80);
        jTableTasks.getColumnModel().getColumn(2).setMinWidth(60);
        jTableTasks.getColumnModel().getColumn(2).setPreferredWidth(60);
        jTableTasks.getColumnModel().getColumn(2).setMaxWidth(60);

        javax.swing.GroupLayout jPanelTasksLayout = new javax.swing.GroupLayout(jPanelTasks);
        jPanelTasks.setLayout(jPanelTasksLayout);
        jPanelTasksLayout.setHorizontalGroup(
            jPanelTasksLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 741, Short.MAX_VALUE)
        );
        jPanelTasksLayout.setVerticalGroup(
            jPanelTasksLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE)
        );

        mainTabbedPane.addTab("Tasks", jPanelTasks);

        jTableCallLogs.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Name", "Date", "Status", "Duration"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableCallLogs.setToolTipText("");
        jTableCallLogs.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        jTableCallLogs.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableCallLogsMouseClicked(evt);
            }
        });
        jTableCallLogs.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                jTableCallLogsMouseMoved(evt);
            }
        });
        jScrollPane5.setViewportView(jTableCallLogs);
        jTableCallLogs.getColumnModel().getColumn(0).setMinWidth(100);
        jTableCallLogs.getColumnModel().getColumn(0).setPreferredWidth(170);
        jTableCallLogs.getColumnModel().getColumn(0).setMaxWidth(300);
        jTableCallLogs.getColumnModel().getColumn(1).setMinWidth(170);
        jTableCallLogs.getColumnModel().getColumn(1).setPreferredWidth(180);
        jTableCallLogs.getColumnModel().getColumn(1).setMaxWidth(300);
        jTableCallLogs.getColumnModel().getColumn(2).setMinWidth(100);
        jTableCallLogs.getColumnModel().getColumn(2).setPreferredWidth(100);
        jTableCallLogs.getColumnModel().getColumn(2).setMaxWidth(300);
        jTableCallLogs.getColumnModel().getColumn(3).setMinWidth(60);
        jTableCallLogs.getColumnModel().getColumn(3).setPreferredWidth(60);
        jTableCallLogs.getColumnModel().getColumn(3).setMaxWidth(60);

        javax.swing.GroupLayout jPanelCallLogsLayout = new javax.swing.GroupLayout(jPanelCallLogs);
        jPanelCallLogs.setLayout(jPanelCallLogsLayout);
        jPanelCallLogsLayout.setHorizontalGroup(
            jPanelCallLogsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 741, Short.MAX_VALUE)
        );
        jPanelCallLogsLayout.setVerticalGroup(
            jPanelCallLogsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE)
        );

        mainTabbedPane.addTab("Call Logs", jPanelCallLogs);

        status_label7.setFont(new java.awt.Font("Tahoma", 0, 18));
        status_label7.setText("Coming Soon");

        javax.swing.GroupLayout jPanelCalendarLayout = new javax.swing.GroupLayout(jPanelCalendar);
        jPanelCalendar.setLayout(jPanelCalendarLayout);
        jPanelCalendarLayout.setHorizontalGroup(
            jPanelCalendarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCalendarLayout.createSequentialGroup()
                .addGap(306, 306, 306)
                .addComponent(status_label7, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
                .addGap(306, 306, 306))
        );
        jPanelCalendarLayout.setVerticalGroup(
            jPanelCalendarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCalendarLayout.createSequentialGroup()
                .addGap(211, 211, 211)
                .addComponent(status_label7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(219, 219, 219))
        );

        mainTabbedPane.addTab("Calendar", jPanelCalendar);

        status_label6.setFont(new java.awt.Font("Tahoma", 0, 18));
        status_label6.setText("Coming Soon");

        javax.swing.GroupLayout jPanelOptionsLayout = new javax.swing.GroupLayout(jPanelOptions);
        jPanelOptions.setLayout(jPanelOptionsLayout);
        jPanelOptionsLayout.setHorizontalGroup(
            jPanelOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelOptionsLayout.createSequentialGroup()
                .addGap(306, 306, 306)
                .addComponent(status_label6, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
                .addGap(306, 306, 306))
        );
        jPanelOptionsLayout.setVerticalGroup(
            jPanelOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelOptionsLayout.createSequentialGroup()
                .addGap(211, 211, 211)
                .addComponent(status_label6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(219, 219, 219))
        );

        mainTabbedPane.addTab("Options", jPanelOptions);

        status_label.setFont(new java.awt.Font("Tahoma", 0, 12));
        status_label.setText("Welcome to IPDdump - http://code.google.com/p/ipddump/");

        jProgressBar1.setFocusable(false);

        fileMenu.setText("File");

        openMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        openMenuItem.setText("Open");
        openMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                openMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(openMenuItem);

        saveAsMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        saveAsMenuItem.setText("Save Selected As ...");
        saveAsMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveAsMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(saveAsMenuItem);
        fileMenu.add(jSeparator1);

        exitMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        jMenuSettings.setText("Options");

        ResolveCheckBox.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_MASK));
        ResolveCheckBox.setSelected(true);
        ResolveCheckBox.setText("Resolve Names?");
        ResolveCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ResolveCheckBoxActionPerformed(evt);
            }
        });
        jMenuSettings.add(ResolveCheckBox);

        TollTipsBoxMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.CTRL_MASK));
        TollTipsBoxMenuItem.setSelected(true);
        TollTipsBoxMenuItem.setText("Tool Tips");
        jMenuSettings.add(TollTipsBoxMenuItem);

        AdrrBookAllCheckBox.setText("Use Adrress Book-All DB");
        AdrrBookAllCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AdrrBookAllCheckBoxActionPerformed(evt);
            }
        });
        jMenuSettings.add(AdrrBookAllCheckBox);

        menuBar.add(jMenuSettings);

        jMenuHelp.setText("Help");

        jMenuItemAbout.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0));
        jMenuItemAbout.setText("About");
        jMenuItemAbout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAboutActionPerformed(evt);
            }
        });
        jMenuHelp.add(jMenuItemAbout);

        menuBar.add(jMenuHelp);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mainTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 746, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addComponent(status_label, javax.swing.GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(mainTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 471, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(status_label)
                    .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        mainTabbedPane.getAccessibleContext().setAccessibleName("tabbedPane");

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-762)/2, (screenSize.height-560)/2, 762, 560);
    }// </editor-fold>//GEN-END:initComponents

    public IpdDump_NewGUI() {
        initComponents();
        setTitle("IPDdump v" + rb.getString("version"));
        jPopupMenu.remove(jMenuItemCSV);//No need to see the CSV output.. Still works under the Copy popup menu.
        jMenuSpSMS.remove(jMenuItemSelectedSMSCSV);
        jMenuSpCallLogs.remove(jMenuItemSelectedCallLogsCSV);
        viewer = new DataViewer();
        IpdChooser.setAcceptAllFileFilterUsed(false);
        IpdChooser.setFileHidingEnabled(false);
        IpdChooser.setMultiSelectionEnabled(false);
        IpdChooser.addChoosableFileFilter(
                new ExtensionFileFilter(
                new String[]{".IPD"}, "BB Backup Files"));

        jFileChooser1.setAcceptAllFileFilterUsed(false);
        jFileChooser1.setFileHidingEnabled(false);
        jFileChooser1.addChoosableFileFilter(
                new ExtensionFileFilter(
                new String[]{".csv"}, "Csv Document *.csv"));
        jFileChooser1.addChoosableFileFilter(
                new ExtensionFileFilter(
                new String[]{".xml"}, "Xml Document *.xml"));
        jFileChooser1.addChoosableFileFilter(
                new ExtensionFileFilter(
                new String[]{".txt"}, "Text Document *.txt"));

        SMSDataModel = jTableSMS.getModel();
        ContactsDataModel = jTableContacts.getModel();
        MemosDataModel = jTableMemos.getModel();
        TasksDataModel = jTableTasks.getModel();
        CallLogsDataModel = jTableCallLogs.getModel();
        
//        jTableCallLogs.setAutoCreateRowSorter(true);
//        jTableTasks.setAutoCreateRowSorter(true);
//        jTableMemos.setAutoCreateRowSorter(true);
//        jTableSMS.setAutoCreateRowSorter(true);
//        jTableContacts.setAutoCreateRowSorter(true);

        SMStabINDEX = mainTabbedPane.indexOfTab("SMS");
        ContactstabINDEX = mainTabbedPane.indexOfTab("Contacts");
        CalendartabINDEX = mainTabbedPane.indexOfTab("Calendar");
        TaskstabINDEX = mainTabbedPane.indexOfTab("Tasks");
        OptionstabINDEX = mainTabbedPane.indexOfTab("Options");
        MemostabINDEX = mainTabbedPane.indexOfTab("Memos");
        CallLogstabINDEX = mainTabbedPane.indexOfTab("Call Logs");
        ActiveTAB = mainTabbedPane.getSelectedIndex();

//        jLabel1.setText("");

        if (rb.getString("ResolveNames").equalsIgnoreCase("true")) {
        ResolveCheckBox.setSelected(true);}
        else if(rb.getString("ResolveNames").equalsIgnoreCase("false"))
        {ResolveCheckBox.setSelected(false);
        }

        if (rb.getString("toolTips").equalsIgnoreCase("true")) {
        TollTipsBoxMenuItem.setSelected(true);}
        else if(rb.getString("toolTips").equalsIgnoreCase("false"))
        {TollTipsBoxMenuItem.setSelected(false);
        }

        if (rb.getString("UseAdrrBook").equalsIgnoreCase("true")) {
        AdrrBookAllCheckBox.setSelected(true);}
        else if(rb.getString("UseAdrrBook").equalsIgnoreCase("false"))
        {AdrrBookAllCheckBox.setSelected(false);
        }

        status_label.setText(welcomeMsg);
        saveAsMenuItem.setEnabled(false);
        jProgressBar1.setVisible(false);
        jProgressBar1.setStringPainted(true);
    }
    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        System.exit(0);
    }//GEN-LAST:event_exitMenuItemActionPerformed

    private void openMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openMenuItemActionPerformed

        JOptionPane.showMessageDialog(MessageFrame, "If your language in not yet supported please consider sending me your ipd file\n"
                + "I will use this file ONLY for the purpose of making this application better!\n\n"
                + "This message will be removed when the application reaches version 1.0");
        status_label.setText("WORKING...  be patient!");
        if (JFileChooser.APPROVE_OPTION == IpdChooser.showOpenDialog(null)) {
             startTime = System.currentTimeMillis();
            jFileChooser1.setSelectedFile(IpdChooser.getSelectedFile());
            setTitle("IPDdump " + jFileChooser1.getSelectedFile().getPath());

//            try {
                 String[] args = {IpdChooser.getSelectedFile().getPath()};
                 parser = new IPDParser(args[0]);
                parser.enableDebuging(); // TODO: Comment This Line Before Publish
                //parser.enableValuePeeking(); // TODO: Comment This Line Before Publish
                if (database!=null&&  database.contacts().iterator().hasNext()){
                    database.contacts().iterator().next().setAdrrBookAllrecordsToZero();
                }


           Runnable r = new Runnable() {
            @Override
            public void run() {
                jProgressBar1.setVisible(true);
                int percentage=0;
                do{

                            try {
                                Thread.sleep(100);
                            } catch (InterruptedException ex) {
                                Logger.getLogger(IpdDump_NewGUI.class.getName()).log(Level.SEVERE, null, ex);
                            }
             percentage=parser.getCompletedPersentage();
             jProgressBar1.setValue(percentage);
             
            }while ( percentage<100 && percentage!=-1 && percentage!=-2);
            jProgressBar1.setVisible(false);}
        };
        

        Thread t = new Thread(r);

        t.setDaemon(true);
        t.start();

            Runnable r1 = new Runnable() {
            @Override
            public void run() {
try {
                database = parser.parse();


            resolveContactsNames = ResolveCheckBox.isSelected();
            historyMaker = new HistoryMaker(database, resolveContactsNames);

            SMS = new SmsWriters(database, resolveContactsNames);
            totalSMS = SMS.getSize();

            Contacts = new ContactsWriters(database);
           if (database.contacts().
                     iterator().hasNext()){
               if (AdrrBookAllCheckBox.isSelected())
                 {
            totalContacts = database.contacts().iterator().next().
                    getAdrrBookAllrecordsCount();
             } else {
             totalContacts = Math.abs(database.contacts().size()-database.contacts().
                     iterator().next().getAdrrBookAllrecordsCount());
               }

             AdrrBookAllCheckBox.setToolTipText(database.contacts().
                     iterator().next().getAdrrBookAllrecordsCount()+" records");
            }
            finder = new Finder(database);


            Memos = new MemosWriters(database);
            totalMemos = Memos.getSize();

            CallLogs = new CallLogsWriters(database);
            totalCallLogs = CallLogs.getSize();


            Tasks = new TasksWriters(database);
            totalTasks = Tasks.getSize();


            fillTables();
            long endTime = System.currentTimeMillis() - startTime;
            tempWelcomeMsg = welcomeMsg + " --> Load Time: " + (endTime / 1000.0) + "sec";
            status_label.setText(tempWelcomeMsg);

            } catch (IOException ex) {
                JOptionPane.showMessageDialog(MessageFrame, "ERROR: " + ex.getMessage());
                ex.printStackTrace();
                saveAsMenuItem.setEnabled(false);
            }
            }
        };


        Thread t1 = new Thread(r1);
        t1.setDaemon(true);
        t1.start();

        jProgressBar1.setVisible(true);


            


        } else {
            status_label.setText(tempWelcomeMsg);
        }
    }//GEN-LAST:event_openMenuItemActionPerformed

    private void fillTables() {

        if (database.isIsDatabaseEncrypded()){
        JOptionPane.showMessageDialog(MessageFrame, "Encrypded Database Found\nError");}

        Runnable r1 = new Runnable() {

            @Override
            public void run() {
                fillSMSTable();
            }
        };
        Thread t1 = new Thread(r1);
        t1.setDaemon(false);
        t1.start();

        Runnable r2 = new Runnable() {

            @Override
            public void run() {
                fillContactsTable();
            }
        };
        Thread t2 = new Thread(r2);
        t2.setDaemon(false);
        t2.start();

        Runnable r3 = new Runnable() {

            @Override
            public void run() {
                fillMemosTable();
                fillTasksTable();
            }
        };
        Thread t3 = new Thread(r3);
        t3.setDaemon(false);
        t3.start();

//        Runnable r4 = new Runnable() {
//            public void run() {
//
//            }
//        };
//        Thread t4 = new Thread(r4);
//        t4.setDaemon(false);
//        t4.start();

        Runnable r5 = new Runnable() {

            @Override
            public void run() {
                fillCallLogsTable();
            }
        };
        Thread t5 = new Thread(r5);
        t5.setDaemon(false);
        t5.start();

        saveAsMenuItem.setEnabled(true);
    }

    private void fillCallLogsTable() {
        CallLogsTablePrepair();

        mainTabbedPane.setTitleAt(CallLogstabINDEX, "Call Logs (" + totalCallLogs + ")");
        int i = 0;

        for (CallLog record : database.getCallLogs()) {

            CallLogsDataModel.setValueAt(record.getName(), i, CallLogsNameIndex);
            CallLogsDataModel.setValueAt(record.getDate().toString(), i, CallLogsDateIndex);
            CallLogsDataModel.setValueAt(record.getStatus(), i, CallLogsStatusIndex);
            CallLogsDataModel.setValueAt(record.getDuration(), i, CallLogsDurationIndex);
            i++;//Go to next Line in the table

        }
    }

    private void fillSMSTable() {

        smsTablePrepair();
        mainTabbedPane.setTitleAt(SMStabINDEX, "SMS (" + totalSMS + ")");
        int i = 0;
        String sSent = "";
        String Name = "";

        for (SMSMessage record : database.getSMSRecords()) {
            if (record.wasSent()) {
                sSent = "sent";
            } else {
                sSent = "received";
            }
//            renderer.setWasSent(record.wasSent());
//            jTableSMS.getColumnModel().getColumn(0).setCellRenderer(renderer);
//            
            if (resolveContactsNames) {
                finder.useAdrrBookAll(AdrrBookAllCheckBox.isSelected());

                Name = finder.findContactByPhoneNumber(record.getNumber());
            } else {
                Name = record.getNumber();
            }
            SMSDataModel.setValueAt(sSent, i, SMSWasSentIndex);
            SMSDataModel.setValueAt(Name, i, SMSNumberIndex);
            SMSDataModel.setValueAt(record.getText(), i, SMSTextIndex);
            SMSDataModel.setValueAt(record.getSent().toString(), i, SMSSentIndex);
            SMSDataModel.setValueAt(record.getReceived().toString(), i, SMSReceivedIndex);
            i++;//Go to next Line in the table
        }
    }

    private void fillContactsTable() {

        if (AdrrBookAllCheckBox.isSelected() && database.contacts().iterator().hasNext())
        {
        totalContacts = database.contacts().iterator().next().getAdrrBookAllrecordsCount();
        } else if (database.contacts().iterator().hasNext()){
        totalContacts = Math.abs(database.contacts().size()-database.contacts().iterator().next().getAdrrBookAllrecordsCount());
        }
        ContactsTablePrepair();
        mainTabbedPane.setTitleAt(ContactstabINDEX, "Contacts (" + totalContacts + ")");
        int i = 0;
//        System.out.println("TOTAL CONTACS FOUND: "+database.contacts().size());
//        System.out.println("TOTAL ALL CONTACS FOUND: "+database.contacts().iterator().next().getAdrrBookAllrecordsCount());
        for (Contact record : database.contacts()) {
            if (record.isAdrrBookAllDB()==AdrrBookAllCheckBox.isSelected()){
            ContactsDataModel.setValueAt(record.getName(), i, ContactsNameIndex);
            ContactsDataModel.setValueAt(record.getEmail(), i, ContactsEmailIndex);
            ContactsDataModel.setValueAt(record.getMobilePhone(), i, ContactsMobileIndex);
            ContactsDataModel.setValueAt(record.getHomePhone(), i, ContactsHomeNumberIndex);
            ContactsDataModel.setValueAt(record.getWorkPhone(), i, ContactsWorkIndex);
            ContactsDataModel.setValueAt(record.getNotes(), i, ContactsNotesIndex);
            i++;//Go to next Line in the table
            }

        }
    }

    private void fillMemosTable() {
        MemoTablePrepair();
        mainTabbedPane.setTitleAt(MemostabINDEX, "Memos (" + totalMemos + ")");
        int i = 0;

        for (Memo record : database.getMemos()) {

            MemosDataModel.setValueAt(record.getTitle(), i, MemosTitleIndex);
            MemosDataModel.setValueAt(record.getMemo(), i, MemosMemoIndex);
            i++;//Go to next Line in the table
        }
    }

    private void fillTasksTable() {
        TasksTablePrepair();
        mainTabbedPane.setTitleAt(TaskstabINDEX, "Tasks (" + totalTasks + ")");
        int i = 0;

        for (Task record : database.getTasks()) {

            TasksDataModel.setValueAt(record.getTask(), i, TaskTitleIndex);
            TasksDataModel.setValueAt(record.getStatus(), i, TaskStatusIndex);
            TasksDataModel.setValueAt(record.getPriority(), i, TaskPriorityIndex);
            TasksDataModel.setValueAt(record.getDue(), i, TasksDueIndex);
            TasksDataModel.setValueAt(record.getReminder(), i, TasksReminderIndex);
            TasksDataModel.setValueAt(record.getNotes(), i, TasksNotesIndex);
            TasksDataModel.setValueAt(record.getTimeZone(), i, TasksTimeZoneIndex);
            i++;//Go to next Line in the table
        }
    }

    private void jTableSMSMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableSMSMouseClicked
        tableClick(evt);
}//GEN-LAST:event_jTableSMSMouseClicked

    private void saveAsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsMenuItemActionPerformed
        SMSSelectedRows = jTableSMS.getSelectedRows();
        ContactsSelectedRows = jTableContacts.getSelectedRows();
        MemosSelectedRows = jTableMemos.getSelectedRows();
        ActiveTAB = mainTabbedPane.getSelectedIndex();


        if (ActiveTAB == SMStabINDEX && totalSMS != 0 && SMSSelectedRows.length > 0) {
            if (saveDialog()) {
                if (ext.equalsIgnoreCase("txt")) {
                    fileWriter.writeTextToFile(fileToSave, SMS.toPlainText(SMSSelectedRows), ".txt");
                } else if (ext.equalsIgnoreCase("csv")) {
                    fileWriter.writeTextToFile(fileToSave, SMS.toCSV(SMSSelectedRows), ".csv");
                } else if (ext.equalsIgnoreCase("xml")) {
                    fileWriter.writeXMLtoFile(fileToSave, SMS.toXML(SMSSelectedRows));
                }
            }
        } else if (ActiveTAB == ContactstabINDEX && totalContacts != 0 && ContactsSelectedRows.length > 0) {
            if (saveDialog()) {
                if (ext.equalsIgnoreCase("txt")) {
                    fileWriter.writeTextToFile(fileToSave, Contacts.toPlainText(ContactsSelectedRows), ".txt");
                } else if (ext.equalsIgnoreCase("csv")) {
                    fileWriter.writeTextToFile(fileToSave, Contacts.toCSV(ContactsSelectedRows), ".csv");
                } else if (ext.equalsIgnoreCase("xml")) {
                    fileWriter.writeXMLtoFile(fileToSave, Contacts.toXML(ContactsSelectedRows));
                }
            }
        } else if (ActiveTAB == MemostabINDEX && totalMemos != 0 && MemosSelectedRows.length > 0) {
            if (saveDialog()) {
                if (ext.equalsIgnoreCase("txt")) {
                    fileWriter.writeTextToFile(fileToSave, Memos.toPlainText(MemosSelectedRows), ".txt");
                } else if (ext.equalsIgnoreCase("csv")) {
                    fileWriter.writeTextToFile(fileToSave, Memos.toCSV(MemosSelectedRows), ".csv");
                } else if (ext.equalsIgnoreCase("xml")) {
                    fileWriter.writeXMLtoFile(fileToSave, Memos.toXML(MemosSelectedRows));
                }
            }
        } else if (ActiveTAB == TaskstabINDEX && totalTasks != 0 && TasksSelectedRows.length > 0) {
            if (saveDialog()) {
                if (ext.equalsIgnoreCase("txt")) {
                    fileWriter.writeTextToFile(fileToSave, Tasks.toPlainText(TasksSelectedRows), ".txt");
                } else if (ext.equalsIgnoreCase("csv")) {
                    fileWriter.writeTextToFile(fileToSave, Tasks.toCSV(TasksSelectedRows), ".csv");
                } else if (ext.equalsIgnoreCase("xml")) {
                    fileWriter.writeXMLtoFile(fileToSave, Tasks.toXML(TasksSelectedRows));
                }
            }
        } else if (ActiveTAB == CallLogstabINDEX && totalCallLogs != 0 && CallLogsSelectedRows.length > 0) {
            if (saveDialog()) {
                if (ext.equalsIgnoreCase("txt")) {
                    fileWriter.writeTextToFile(fileToSave, CallLogs.toPlainText(CallLogsSelectedRows), ".txt");
                } else if (ext.equalsIgnoreCase("csv")) {
                    fileWriter.writeTextToFile(fileToSave, CallLogs.toCSV(CallLogsSelectedRows), ".csv");
                } else if (ext.equalsIgnoreCase("xml")) {
                    fileWriter.writeXMLtoFile(fileToSave, CallLogs.toXML(CallLogsSelectedRows));
                }
            }
        } else {
            JOptionPane.showMessageDialog(MessageFrame, "Select the items you want to save");
        }


    }//GEN-LAST:event_saveAsMenuItemActionPerformed

    private boolean saveDialog() {
        if (JFileChooser.APPROVE_OPTION == jFileChooser1.showSaveDialog(null)) {

            int lastDot = jFileChooser1.getFileFilter().getDescription().lastIndexOf(".") + 1;
            ext = jFileChooser1.getFileFilter().getDescription().substring(lastDot);
            fileToSave = jFileChooser1.getSelectedFile().getAbsolutePath() + "." + ext;
            //System.out.println(fToSave+" - "+ext);
            return true;
        }
        return false;
    }

    private void ShowPopup(MouseEvent e) {
        jPopupMenu.show(e.getComponent(),
                e.getX(), e.getY());
    }

    private void jMenuItemXMLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemXMLActionPerformed
        String tmp = "";
        if (ActiveTAB == SMStabINDEX && totalSMS != 0 && SMSSelectedRows.length > 0) {
            tmp = SMS.toXML(SMSSelectedRows).asXML();
            viewer.setTitle("SMS Viewer - XML");
        } else if (ActiveTAB == ContactstabINDEX && totalContacts != 0 && ContactsSelectedRows.length > 0) {
            tmp = Contacts.toXML(ContactsSelectedRows).asXML();
            viewer.setTitle("Contacts Viewer - XML");
        } else if (ActiveTAB == MemostabINDEX && totalMemos != 0 && MemosSelectedRows.length > 0) {
            tmp = Memos.toXML(MemosSelectedRows).asXML();
            viewer.setTitle("Memos Viewer - XML");
        } else if (ActiveTAB == TaskstabINDEX && totalTasks != 0 && TasksSelectedRows.length > 0) {
            tmp = Tasks.toXML(TasksSelectedRows).asXML();
            viewer.setTitle("Tasks Viewer - XML");
        } else if (ActiveTAB == CallLogstabINDEX && totalCallLogs != 0 && CallLogsSelectedRows.length > 0) {
            tmp = CallLogs.toXML(CallLogsSelectedRows).asXML();
            viewer.setTitle("Call Logs Viewer - XML");
        }


        viewer.setXml(tmp);
        viewer.setVisible(true);
}//GEN-LAST:event_jMenuItemXMLActionPerformed

    private void jMenuItemTxtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemTxtActionPerformed

        String tmp = "";
        if (ActiveTAB == SMStabINDEX && totalSMS != 0 && SMSSelectedRows.length > 0) {
            tmp = SMS.toPlainText(SMSSelectedRows);
            viewer.setTitle("SMS Viewer - Plain Text");
        } else if (ActiveTAB == ContactstabINDEX && totalContacts != 0 && ContactsSelectedRows.length > 0) {
            tmp = Contacts.toPlainText(ContactsSelectedRows);
            viewer.setTitle("Contacts Viewer - Plain Text");
        } else if (ActiveTAB == MemostabINDEX && totalMemos != 0 && MemosSelectedRows.length > 0) {
            tmp = Memos.toPlainText(MemosSelectedRows);
            viewer.setTitle("Memos Viewer - Plain Text");
        } else if (ActiveTAB == TaskstabINDEX && totalTasks != 0 && TasksSelectedRows.length > 0) {
            tmp = Tasks.toPlainText(TasksSelectedRows);
            viewer.setTitle("Tasks Viewer - Plain Text");
        } else if (ActiveTAB == CallLogstabINDEX && totalCallLogs != 0 && CallLogsSelectedRows.length > 0) {
            tmp = CallLogs.toPlainText(CallLogsSelectedRows);
            viewer.setTitle("Call Logs Viewer -  Plain Text");
        }

        viewer.setTxt(tmp);
        viewer.setVisible(true);
}//GEN-LAST:event_jMenuItemTxtActionPerformed

    private void jMenuItemCSVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCSVActionPerformed
        String tmp = "";

        if (ActiveTAB == SMStabINDEX && totalSMS != 0 && SMSSelectedRows.length > 0) {
            tmp = SMS.toCSV(SMSSelectedRows);
            viewer.setTitle("SMS Viewer - Csv");
        } else if (ActiveTAB == ContactstabINDEX && totalContacts != 0 && ContactsSelectedRows.length > 0) {
            tmp = Contacts.toCSV(ContactsSelectedRows);
            viewer.setTitle("Contacts Viewer - Csv");
        } else if (ActiveTAB == MemostabINDEX && totalMemos != 0 && MemosSelectedRows.length > 0) {
            tmp = Memos.toCSV(MemosSelectedRows);
            viewer.setTitle("Memos Viewer - Csv");
        } else if (ActiveTAB == TaskstabINDEX && totalTasks != 0 && TasksSelectedRows.length > 0) {
            tmp = Tasks.toCSV(TasksSelectedRows);
            viewer.setTitle("Tasks Viewer - Csv");
        } else if (ActiveTAB == CallLogstabINDEX && totalCallLogs != 0 && CallLogsSelectedRows.length > 0) {
            tmp = CallLogs.toCSV(CallLogsSelectedRows);
            viewer.setTitle("Call Logs Viewer - Csv");
        }

        viewer.setCvs(tmp);

        viewer.setVisible(true);
}//GEN-LAST:event_jMenuItemCSVActionPerformed

    private void jMenuItemCPTXTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCPTXTActionPerformed
        String tmp = "";
        if (ActiveTAB == SMStabINDEX && totalSMS != 0 && SMSSelectedRows.length > 0) {
            tmp = SMS.toPlainText(SMSSelectedRows);
        } else if (ActiveTAB == ContactstabINDEX && totalContacts != 0 && ContactsSelectedRows.length > 0) {
            tmp = Contacts.toPlainText(ContactsSelectedRows);
        } else if (ActiveTAB == MemostabINDEX && totalMemos != 0 && MemosSelectedRows.length > 0) {
            tmp = Memos.toPlainText(MemosSelectedRows);
        } else if (ActiveTAB == TaskstabINDEX && totalTasks != 0 && TasksSelectedRows.length > 0) {
            tmp = Tasks.toPlainText(TasksSelectedRows);
        } else if (ActiveTAB == CallLogstabINDEX && totalCallLogs != 0 && CallLogsSelectedRows.length > 0) {
            tmp = CallLogs.toPlainText(CallLogsSelectedRows);
        }
        setClipboardContents(tmp);
}//GEN-LAST:event_jMenuItemCPTXTActionPerformed

    private void jMenuItemCPXMLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCPXMLActionPerformed
        String tmp = "";
        if (ActiveTAB == SMStabINDEX && totalSMS != 0 && SMSSelectedRows.length > 0) {
            tmp = SMS.toXML(SMSSelectedRows).asXML();
        } else if (ActiveTAB == ContactstabINDEX && totalContacts != 0 && ContactsSelectedRows.length > 0) {
            tmp = Contacts.toXML(ContactsSelectedRows).asXML();
        } else if (ActiveTAB == MemostabINDEX && totalMemos != 0 && MemosSelectedRows.length > 0) {
            tmp = Memos.toXML(MemosSelectedRows).asXML();
        } else if (ActiveTAB == TaskstabINDEX && totalTasks != 0 && TasksSelectedRows.length > 0) {
            tmp = Tasks.toXML(TasksSelectedRows).asXML();
        } else if (ActiveTAB == CallLogstabINDEX && totalCallLogs != 0 && CallLogsSelectedRows.length > 0) {
            tmp = CallLogs.toXML(CallLogsSelectedRows).asXML();
        }
        setClipboardContents(tmp);
}//GEN-LAST:event_jMenuItemCPXMLActionPerformed

    private void jMenuItemCPCSVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCPCSVActionPerformed
        String tmp = "";

        if (ActiveTAB == SMStabINDEX && totalSMS != 0 && SMSSelectedRows.length > 0) {
            tmp = SMS.toCSV(SMSSelectedRows);
        } else if (ActiveTAB == ContactstabINDEX && totalContacts != 0 && ContactsSelectedRows.length > 0) {
            tmp = Contacts.toCSV(ContactsSelectedRows);
        } else if (ActiveTAB == MemostabINDEX && totalMemos != 0 && MemosSelectedRows.length > 0) {
            tmp = Memos.toCSV(MemosSelectedRows);
        } else if (ActiveTAB == TaskstabINDEX && totalTasks != 0 && TasksSelectedRows.length > 0) {
            tmp = Tasks.toCSV(TasksSelectedRows);
        } else if (ActiveTAB == CallLogstabINDEX && totalCallLogs != 0 && CallLogsSelectedRows.length > 0) {
            tmp = CallLogs.toCSV(CallLogsSelectedRows);
        }
        setClipboardContents(tmp);
}//GEN-LAST:event_jMenuItemCPCSVActionPerformed

    private void jTableContactsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableContactsMouseClicked
        tableClick(evt);
}//GEN-LAST:event_jTableContactsMouseClicked
    private void tableClick(java.awt.event.MouseEvent evt) {
        int[] SelectedRows = new int[0];
        String evtObj = null;
        ActiveTAB = mainTabbedPane.getSelectedIndex();

        if (ActiveTAB == SMStabINDEX) {
            SelectedRows = SMSSelectedRows = jTableSMS.getSelectedRows();
            evtObj = "SMS messages";
            jPopupMenu.remove(jSeparator);
            jPopupMenu.remove(jMenuSpSMS);
            jPopupMenu.remove(jMenuSpCallLogs);
            jPopupMenu.add(jMenuHistory);
            jMenuItemViewHistoryTXT.setToolTipText("View the Conversation only of " +
                    "the selected  phone number/s");
            jMenuItemViewHistoryXML.setToolTipText("View the Conversation only of " +
                    "the selected phone number/s");

            jMenuHistory.setText("View Conversation");
            jMenuItemViewHistoryTXT.setText("View Conversation - TXT");
            jMenuItemViewHistoryXML.setText("View Conversation - XML");
        } else if (ActiveTAB == ContactstabINDEX) {
            SelectedRows = ContactsSelectedRows = jTableContacts.getSelectedRows();
            evtObj = "Contacts";
            jPopupMenu.add(jSeparator);
            if (totalSMS > 0) {
                jPopupMenu.add(jMenuSpSMS);
            } else {
                jPopupMenu.remove(jMenuSpSMS);
            }
            if (totalCallLogs > 0) {
                jPopupMenu.add(jMenuSpCallLogs);
            } else {
                jPopupMenu.remove(jMenuSpCallLogs);
            }
            if (totalCallLogs > 0 || totalSMS > 0) {
                jPopupMenu.add(jMenuHistory);
                jMenuHistory.setText("View History");
                jMenuItemViewHistoryTXT.setText("View Contact/s History - TXT");
                jMenuItemViewHistoryXML.setText("View Contact/s History - XML");
                jMenuItemViewHistoryTXT.setToolTipText("View the Call Log and Sms " +
                        "History of the selected Contact/s");
                jMenuItemViewHistoryXML.setToolTipText("View the Call Log and Sms " +
                        "History of the selected Contact/s");
            }
        } else if (ActiveTAB == MemostabINDEX) {
            SelectedRows = MemosSelectedRows = jTableMemos.getSelectedRows();
            evtObj = "Memos";
            jPopupMenu.remove(jSeparator);
            jPopupMenu.remove(jMenuHistory);
            jPopupMenu.remove(jMenuSpSMS);
            jPopupMenu.remove(jMenuSpCallLogs);
        } else if (ActiveTAB == TaskstabINDEX) {
            SelectedRows = TasksSelectedRows = jTableTasks.getSelectedRows();
            evtObj = "Tasks";
            jPopupMenu.remove(jSeparator);
            jPopupMenu.remove(jMenuHistory);
            jPopupMenu.remove(jMenuSpSMS);
            jPopupMenu.remove(jMenuSpCallLogs);
        } else if (ActiveTAB == CallLogstabINDEX) {
            SelectedRows = CallLogsSelectedRows = jTableCallLogs.getSelectedRows();
            evtObj = "Call Logs";
            jPopupMenu.remove(jSeparator);
            jPopupMenu.remove(jMenuSpSMS);
            jPopupMenu.remove(jMenuSpCallLogs);
            jPopupMenu.add(jMenuHistory);
            jMenuHistory.setText("View Call History");
            jMenuItemViewHistoryTXT.setText("View Call History - TXT");
            jMenuItemViewHistoryXML.setText("View Call History - XML");
            jMenuItemViewHistoryTXT.setToolTipText("View This Numbers Call Log History");
            jMenuItemViewHistoryXML.setToolTipText("View This Numbers Call Log History");

        }

        if (evt.getButton() == MouseEvent.BUTTON3 && SelectedRows.length > 0) {
            ShowPopup(evt);
        } else {
            if (evt.getButton() == MouseEvent.BUTTON3 && SelectedRows.length == 0) {
                JOptionPane.showMessageDialog(MessageFrame,
                        "Select the " + evtObj + " you want to View");
            }
        }

        if (evt.getClickCount() == 2) {
            jMenuItemTxtActionPerformed(null);
        }

    }
    private void ResolveCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ResolveCheckBoxActionPerformed
       resolveNames();
    }//GEN-LAST:event_ResolveCheckBoxActionPerformed

    private void resolveNames(){

        if (saveAsMenuItem.isEnabled()) {
            resolveContactsNames = ResolveCheckBox.isSelected();
             historyMaker = new HistoryMaker(database, resolveContactsNames);
             finder.useAdrrBookAll(AdrrBookAllCheckBox.isSelected());
            SMS = new SmsWriters(database, resolveContactsNames);
            fillSMSTable();
        }
    }

    private void jTableMemosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableMemosMouseClicked
        tableClick(evt);
}//GEN-LAST:event_jTableMemosMouseClicked

    private void jMenuItemAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAboutActionPerformed
        new IPDdumpAboutBox(this, false).setVisible(true);
    }//GEN-LAST:event_jMenuItemAboutActionPerformed

    private void jTableTasksMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableTasksMouseClicked
        tableClick(evt);
    }//GEN-LAST:event_jTableTasksMouseClicked

    private void jMenuItemSelectedSMSTxtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSelectedSMSTxtActionPerformed
        int[] selectedRows = new int[0];
        if (ActiveTAB == ContactstabINDEX) {
            selectedRows = finder.findSmsByContacts(ContactsSelectedRows);
        }

        if (selectedRows.length != 0) {
            setRowsSelection(jTableSMS, selectedRows);
            String tmp = SMS.toPlainText(selectedRows);
            viewer.setTitle("SMS Viewer - Plain Text");
            viewer.setTxt(tmp);
            viewer.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(MessageFrame, "No Sms Messages were found for this Contact/s!");
        }
}//GEN-LAST:event_jMenuItemSelectedSMSTxtActionPerformed

    private void jMenuItemSelectedSMSXMLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSelectedSMSXMLActionPerformed
        int[] selectedSMS = new int[0];
        if (ActiveTAB == ContactstabINDEX) {
            selectedSMS = finder.findSmsByContacts(ContactsSelectedRows);
        }
        if (selectedSMS.length != 0) {
            setRowsSelection(jTableSMS, selectedSMS);
            String tmp = SMS.toXML(selectedSMS).asXML();
            viewer.setTitle("SMS Viewer - XML");
            viewer.setXml(tmp);
            viewer.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(MessageFrame, "No Sms Messages were found for this Contact/s!");
        }
}//GEN-LAST:event_jMenuItemSelectedSMSXMLActionPerformed

    private void jMenuItemSelectedSMSCSVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSelectedSMSCSVActionPerformed
        int[] selectedSMS = new int[0];
        if (ActiveTAB == ContactstabINDEX) {
            selectedSMS = finder.findSmsByContacts(ContactsSelectedRows);
        }
        if (selectedSMS.length != 0) {
            setRowsSelection(jTableSMS, selectedSMS);
            String tmp = SMS.toCSV(selectedSMS);
            viewer.setTitle("SMS Viewer - CSV");
            viewer.setTxt(tmp);
            viewer.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(MessageFrame, "No Sms Messages were found for this Contact/s!");
        }
}//GEN-LAST:event_jMenuItemSelectedSMSCSVActionPerformed

    private void jTableCallLogsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableCallLogsMouseClicked
        tableClick(evt);
    }//GEN-LAST:event_jTableCallLogsMouseClicked

    private void jMenuItemSelectedCallLogsTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSelectedCallLogsTextActionPerformed
        int[] selectedRows = null;
        if (ActiveTAB == ContactstabINDEX) {
            selectedRows = finder.findCallLogsByContacts(ContactsSelectedRows);
        }

        if (selectedRows.length != 0) {
            setRowsSelection(jTableCallLogs, selectedRows);
            String tmp = CallLogs.toPlainText(selectedRows);
            viewer.setTitle("Call Logs Viewer - Plain Text");
            viewer.setTxt(tmp);
            viewer.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(MessageFrame, "No Call Logs were found for this Contact/s!");
        }
}//GEN-LAST:event_jMenuItemSelectedCallLogsTextActionPerformed

    private void jMenuItemSelectedCallLogsXMLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSelectedCallLogsXMLActionPerformed
        int[] selectedRows = null;
        if (ActiveTAB == ContactstabINDEX) {
            selectedRows = finder.findCallLogsByContacts(ContactsSelectedRows);
        }

        if (selectedRows.length != 0) {
            setRowsSelection(jTableCallLogs, selectedRows);
            String tmp = CallLogs.toXML(selectedRows).asXML();
            viewer.setTitle("Call Logs Viewer - XML");
            viewer.setTxt(tmp);
            viewer.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(MessageFrame, "No Call Logs were found for this Contact/s!");
        }
}//GEN-LAST:event_jMenuItemSelectedCallLogsXMLActionPerformed

    private void jMenuItemSelectedCallLogsCSVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSelectedCallLogsCSVActionPerformed
        int[] selectedRows = null;
        if (ActiveTAB == ContactstabINDEX) {
            selectedRows = finder.findCallLogsByContacts(ContactsSelectedRows);
        }

        if (selectedRows.length != 0) {
            setRowsSelection(jTableCallLogs, selectedRows);
            String tmp = CallLogs.toCSV(selectedRows);
            viewer.setTitle("Call Logs Viewer - CSV");
            viewer.setTxt(tmp);
            viewer.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(MessageFrame, "No Call Logs were found for this Contact/s!");
        }
}//GEN-LAST:event_jMenuItemSelectedCallLogsCSVActionPerformed

    private void jMenuItemViewHistoryTXTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemViewHistoryTXTActionPerformed
        if (ActiveTAB == ContactstabINDEX) {

            ContactsSelectedRows = jTableContacts.getSelectedRows();
            String tmp = historyMaker.makeSMSandCallHistoryTXT(ContactsSelectedRows);

            if (!tmp.equals("")) {
                setRowsSelection(jTableSMS, historyMaker.getSelectedSMS());
                setRowsSelection(jTableCallLogs, historyMaker.getSelectedCallLogs());
                viewer.setTitle("Complete History - SMS and Call Logs");
                viewer.setTxt(tmp);
                viewer.setVisible(true);
            } else {
                JOptionPane.showMessageDialog(MessageFrame, "No History found for this Contact/s!");
            }
        } else if (ActiveTAB == SMStabINDEX) {
            SMSSelectedRows = jTableSMS.getSelectedRows();
            String tmp = historyMaker.makeSMSCoversationTXT(SMSSelectedRows);
            setRowsSelection(jTableSMS, historyMaker.getSelectedSMS());

            if (!tmp.equals("")) {
                viewer.setTitle("Complete Conversation - SMS");
                viewer.setTxt(tmp);
                viewer.setVisible(true);
            } else {
                JOptionPane.showMessageDialog(MessageFrame, "No History found!");
            }
        } else if (ActiveTAB == CallLogstabINDEX) {
            CallLogsSelectedRows = jTableCallLogs.getSelectedRows();
            String tmp = historyMaker.makeCallLogHistoryTXT(CallLogsSelectedRows);

            if (!tmp.equals("")) {
                setRowsSelection(jTableCallLogs, historyMaker.getSelectedCallLogs());
                viewer.setTitle("Complete Call Log History");
                viewer.setTxt(tmp);
                viewer.setVisible(true);
            } else {
                JOptionPane.showMessageDialog(MessageFrame, "No History found!");
            }
        }
}//GEN-LAST:event_jMenuItemViewHistoryTXTActionPerformed

    private void jMenuItemViewHistoryXMLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemViewHistoryXMLActionPerformed
        if (ActiveTAB == ContactstabINDEX) {
            ContactsSelectedRows = jTableContacts.getSelectedRows();
            String tmp = historyMaker.makeSMSandCallHistoryXML(ContactsSelectedRows);

            if (!tmp.equals("")) {
                setRowsSelection(jTableSMS, historyMaker.getSelectedSMS());
                setRowsSelection(jTableCallLogs, historyMaker.getSelectedCallLogs());
                viewer.setTitle("Complete History in XML - SMS and Call Logs");
                viewer.setTxt(tmp);
                viewer.setVisible(true);
            } else {
                JOptionPane.showMessageDialog(MessageFrame, "No History found for this Contact/s!");
            }
        } else if (ActiveTAB == SMStabINDEX) {
            SMSSelectedRows = jTableSMS.getSelectedRows();
            String tmp = historyMaker.makeSMSCoversationXML(SMSSelectedRows);
            setRowsSelection(jTableSMS, historyMaker.getSelectedSMS());
            if (!tmp.equals("")) {
                viewer.setTitle("Complete Conversation in XML - SMS");
                viewer.setTxt(tmp);
                viewer.setVisible(true);
            } else {
                JOptionPane.showMessageDialog(MessageFrame, "No History found!");
            }
        } else if (ActiveTAB == CallLogstabINDEX) {
            CallLogsSelectedRows = jTableCallLogs.getSelectedRows();
            String tmp = historyMaker.makeCallLogHistoryXML(CallLogsSelectedRows);


            if (!tmp.equals("")) {
                setRowsSelection(jTableCallLogs, historyMaker.getSelectedCallLogs());
                viewer.setTitle("Complete Call Log History");
                viewer.setTxt(tmp);
                viewer.setVisible(true);
            } else {
                JOptionPane.showMessageDialog(MessageFrame, "No History found!");
            }
        }
    }//GEN-LAST:event_jMenuItemViewHistoryXMLActionPerformed

    private void mouseMoved(java.awt.event.MouseEvent evt) {
        int SelectedRows=0;
        String tollTipText = null;
        ActiveTAB = mainTabbedPane.getSelectedIndex();
        javax.swing.JTable jTableTemp = null;


        if (ActiveTAB == SMStabINDEX) {
            jTableTemp = jTableSMS;
        } else if (ActiveTAB == ContactstabINDEX) {
            jTableTemp = jTableContacts;
        } else if (ActiveTAB == MemostabINDEX) {
            jTableTemp = jTableMemos;
        } else if (ActiveTAB == TaskstabINDEX) {
            jTableTemp = jTableTasks;
        } else if (ActiveTAB == CallLogstabINDEX) {
            jTableTemp = jTableCallLogs;
        }
//        SelectedRows=jTableTemp.getSelectedRowCount();
        if (TollTipsBoxMenuItem.isSelected()) {

            if (jTableTemp.rowAtPoint(evt.getPoint()) != hoveredRow) {
                hoveredRow = jTableTemp.rowAtPoint(evt.getPoint());
            }
            if (ActiveTAB == SMStabINDEX) {
                tollTipText = SMS.toPlainText(new int[]{hoveredRow});
            } else if (ActiveTAB == ContactstabINDEX) {
                tollTipText = Contacts.toPlainText(new int[]{hoveredRow});
            } else if (ActiveTAB == MemostabINDEX) {
                tollTipText = Memos.toPlainText(new int[]{hoveredRow});
            } else if (ActiveTAB == TaskstabINDEX) {
                tollTipText = Tasks.toPlainText(new int[]{hoveredRow});
            } else if (ActiveTAB == CallLogstabINDEX) {
                tollTipText = CallLogs.toPlainText(new int[]{hoveredRow});
            }
            if (tollTipText.length()>1){
            tollTipText = tollTipText.substring(0, tollTipText.length() - 1);
            tollTipText = wrap("<html>" + tollTipText.replace("\n", "<br>") + "</html>", 50);
            jTableTemp.setToolTipText(tollTipText);}
        } else {
            jTableTemp.setToolTipText(null);
        }
    }

    private void jTableSMSMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableSMSMouseMoved
        mouseMoved(evt);
    }//GEN-LAST:event_jTableSMSMouseMoved

    private void jTableContactsMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableContactsMouseMoved
        mouseMoved(evt);
    }//GEN-LAST:event_jTableContactsMouseMoved

    private void jTableMemosMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableMemosMouseMoved
        mouseMoved(evt);
    }//GEN-LAST:event_jTableMemosMouseMoved

    private void jTableTasksMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableTasksMouseMoved
        mouseMoved(evt);
    }//GEN-LAST:event_jTableTasksMouseMoved

    private void jTableCallLogsMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableCallLogsMouseMoved
        mouseMoved(evt);
    }//GEN-LAST:event_jTableCallLogsMouseMoved

    private void AdrrBookAllCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AdrrBookAllCheckBoxActionPerformed
             if (parser!=null){
            fillContactsTable();
            resolveNames();
        }
    }//GEN-LAST:event_AdrrBookAllCheckBoxActionPerformed

    private void setRowsSelection(final javax.swing.JTable jTable, final int[] selectedRows) {

        Runnable r1 = new Runnable() {

            @Override
            public void run() {
                int start = selectedRows[0];
                int end = selectedRows[selectedRows.length - 1];
                jTable.clearSelection();

                for (int i = 0; i < selectedRows.length - 1; i++) {
                    if (selectedRows[i] == selectedRows[i + 1] + 1) {
                        continue;
                    } else {
                        end = selectedRows[i];
                        jTable.addRowSelectionInterval(start, end);
                        start = selectedRows[i + 1];
                    }
                }
                //select and the last entry
                jTable.addRowSelectionInterval(selectedRows[selectedRows.length - 1], selectedRows[selectedRows.length - 1]);
            // jLabelSelectedRows.setText(String.valueOf(jTable.getSelectedRowCount()));
            }
        };
        Thread t1 = new Thread(r1);

        t1.setDaemon(false);
        t1.start();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                checkVersion(1.6);
                new IpdDump_NewGUI().setVisible(true);
            }
        });
    }

    private static void checkVersion(double minimumVersion) {
        String ver = System.getProperty("java.specification.version");
        if (ver == null) {
            ver = "Unknown";
        }
        String[] v = ver.split("\\.");
        int major = 0;
        int minor = 0;
        try {
            major = Integer.parseInt(v[0]);
            minor = Integer.parseInt(v[1]);
        } catch (Exception e) {
            e.printStackTrace();
        }
        double version = (major * 1000) + minor * 100;
        // 1.5 -> 1005; 1.6 -> 1006; 1.7 -> 1007
        if (version < (minimumVersion * 1000.0)) {
            Toolkit.getDefaultToolkit().beep();
            JOptionPane.showMessageDialog(
                    null,
                    "The used Java Runtime Environment does not meet the minimum requirements.\n" +
                    "This Program needs at least Java " + minimumVersion +
                    " or higher.\n" + "Please update your Java Runtime.\n\n" +
                    "Detected Java Runtime Version: " + ver,
                    "Java Runtime version problem detected", JOptionPane.ERROR_MESSAGE);
            System.exit(1);
        }
    }

    // <editor-fold defaultstate="collapsed" desc="Table Prepair Code - - NEED TO find alternative way of doing this??">
    private void CallLogsTablePrepair() {
        jTableCallLogs.setModel(new javax.swing.table.DefaultTableModel(
                new Object[totalCallLogs][3],
                new String[]{
                    "Name", "Date", "Status", "Duration"
                }) {

            Class[] types = new Class[]{
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean[]{
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });

        jTableCallLogs.getColumnModel().getColumn(0).setMinWidth(100);
        jTableCallLogs.getColumnModel().getColumn(0).setPreferredWidth(170);
        jTableCallLogs.getColumnModel().getColumn(0).setMaxWidth(300);
        jTableCallLogs.getColumnModel().getColumn(1).setMinWidth(170);
        jTableCallLogs.getColumnModel().getColumn(1).setPreferredWidth(180);
        jTableCallLogs.getColumnModel().getColumn(1).setMaxWidth(300);
        jTableCallLogs.getColumnModel().getColumn(2).setMinWidth(100);
        jTableCallLogs.getColumnModel().getColumn(2).setPreferredWidth(100);
        jTableCallLogs.getColumnModel().getColumn(2).setMaxWidth(300);
        jTableCallLogs.getColumnModel().getColumn(3).setMinWidth(60);
        jTableCallLogs.getColumnModel().getColumn(3).setPreferredWidth(60);
        jTableCallLogs.getColumnModel().getColumn(3).setMaxWidth(60);
        jTableCallLogs.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

        CallLogsDataModel = jTableCallLogs.getModel();
    }

    private void TasksTablePrepair() {

        jTableTasks.setModel(new javax.swing.table.DefaultTableModel(
                new Object[totalTasks][6],
                new String[]{
                    "Task", "Status", "Priority", "Due Date", "Reminder", "Notes", "Time Zone"
                }) {

            Class[] types = new Class[]{
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean[]{
                false, false, false, false, false, false, false
            };

            @Override
            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
            }

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        jTableTasks.getColumnModel().getColumn(0).setMinWidth(70);
        jTableTasks.getColumnModel().getColumn(0).setPreferredWidth(100);
        jTableTasks.getColumnModel().getColumn(0).setMaxWidth(250);
        jTableTasks.getColumnModel().getColumn(1).setMinWidth(80);
        jTableTasks.getColumnModel().getColumn(1).setPreferredWidth(80);
        jTableTasks.getColumnModel().getColumn(1).setMaxWidth(80);
        jTableTasks.getColumnModel().getColumn(2).setMinWidth(60);
        jTableTasks.getColumnModel().getColumn(2).setPreferredWidth(60);
        jTableTasks.getColumnModel().getColumn(2).setMaxWidth(60);
        jTableTasks.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

        TasksDataModel = jTableTasks.getModel();
    }

    private void MemoTablePrepair() {
        jTableMemos.setModel(new javax.swing.table.DefaultTableModel(
                new Object[totalMemos][1],
                new String[]{
                    "Title", "Memo"
                }) {

            Class[] types = new Class[]{
                java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean[]{
                false, false
            };

            @Override
            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
            }

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        jTableMemos.getColumnModel().getColumn(0).setMinWidth(100);
        jTableMemos.getColumnModel().getColumn(0).setMaxWidth(250);
        jTableMemos.getColumnModel().getColumn(0).setPreferredWidth(150);
        jTableMemos.getColumnModel().getColumn(1).setPreferredWidth(500);
        jTableMemos.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        MemosDataModel = jTableMemos.getModel();
    }

    private void ContactsTablePrepair() {
        jTableContacts.setModel(new javax.swing.table.DefaultTableModel(
                new Object[totalContacts][5],
                new String[]{
                    "Name", "Email", "Mobile", "Work", "Home", "Notes"
                }) {

            Class[] types = new Class[]{
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean[]{
                false, false, false, false, false, false
            };

            @Override
            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
            }

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        jTableContacts.getColumnModel().getColumn(0).setMinWidth(100);
        jTableContacts.getColumnModel().getColumn(0).setPreferredWidth(150);
        jTableContacts.getColumnModel().getColumn(0).setMaxWidth(300);
        jTableContacts.getColumnModel().getColumn(1).setPreferredWidth(170);
        jTableContacts.getColumnModel().getColumn(1).setMaxWidth(300);
        jTableContacts.getColumnModel().getColumn(2).setMinWidth(120);
        jTableContacts.getColumnModel().getColumn(2).setPreferredWidth(120);
        jTableContacts.getColumnModel().getColumn(2).setMaxWidth(180);
        jTableContacts.getColumnModel().getColumn(3).setMinWidth(120);
        jTableContacts.getColumnModel().getColumn(3).setPreferredWidth(120);
        jTableContacts.getColumnModel().getColumn(3).setMaxWidth(180);
        jTableContacts.getColumnModel().getColumn(4).setMinWidth(120);
        jTableContacts.getColumnModel().getColumn(4).setPreferredWidth(120);
        jTableContacts.getColumnModel().getColumn(4).setMaxWidth(180);
        jTableContacts.getColumnModel().getColumn(5).setMinWidth(60);
        jTableContacts.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        ContactsDataModel = jTableContacts.getModel();
    }

    private void smsTablePrepair() {
        jTableSMS.setModel(new javax.swing.table.DefaultTableModel(
                new Object[totalSMS][4],
                new String[]{
                    "Sent?", "Number", "Text", "Sent Date", "Received Date"
                }) {

            Class[] types = new Class[]{
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean[]{
                false, false, false, false, false
            };

            @Override
            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
            }

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });

        jScrollPane1.setViewportView(jTableSMS);
        jTableSMS.getColumnModel().getColumn(0).setMinWidth(60);
        jTableSMS.getColumnModel().getColumn(0).setPreferredWidth(60);
        jTableSMS.getColumnModel().getColumn(0).setMaxWidth(40);
        jTableSMS.getColumnModel().getColumn(1).setMaxWidth(150);
        jTableSMS.getColumnModel().getColumn(2).setMinWidth(150);
        jTableSMS.getColumnModel().getColumn(3).setMaxWidth(200);
        jTableSMS.getColumnModel().getColumn(4).setMaxWidth(200);
        jTableSMS.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        SMSDataModel = jTableSMS.getModel();
//        jTableSMS.getColumnModel().getColumn(0).setCellRenderer(renderer);
    }// </editor-fold>

    public void setClipboardContents(String aString) {
        StringSelection stringSelection = new StringSelection(aString);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(stringSelection, (ClipboardOwner) null);
    }

    /**
     * <p>Wrap text at a certain line length. Defaults to HTML line break.</p>
     *
     * <pre>
     * StringUtil.wrap("1234512345", 5) = 12345<br>12345
     * StringUtil.wrap("12345", 10) = 12345
     * </pre>
     *
     * @param string The String
     * @param wrapLength The position to create a line break
     *
     * @return String
     */
    private static String wrap(String string, int wrapLength) {
        return wrap(string, null, wrapLength);
    }

    /**
     *
     * <pre>
     * StringUtil.wrap("Hello World!, "<br>", 9) = Hello<br>World!
     * StringUtil.wrap("1234512345", "<br>", 5) = 1234512345
     * StringUtil.wrap("12345", 10) = 12345
     *</pre>
     *
     * @param string The String
     * @param lineSeparator Line break
     * @param wrapLength The position to create a line break
     *
     * @return String
     */
    public static String wrap(String string, String lineSeparator, int wrapLength) {
        if (string.length()>500)string=string.substring(0, 500);
        // Null or blank string should return an empty ("") string
        if (isBlank(string)) {
            return "";
        }

        int stringLength = string.length();

        if (stringLength > wrapLength) {
            //Ensure.ensureArrayIndex(wrapLength, 1, Integer.MAX_VALUE);

            // Default to HTML line break since web app is  client
            if (isBlank(lineSeparator)) {
                lineSeparator = "<br>";
            }

            StringBuffer sb = new StringBuffer(stringLength + ((stringLength / wrapLength) * 2 * lineSeparator.length()));
            BreakIterator lineIterator = BreakIterator.getLineInstance();
            lineIterator.setText(string);
            int start = lineIterator.first();
            int lineStart = start;

            for (int end = lineIterator.next(); end != BreakIterator.DONE; start = end, end = lineIterator.next()) {
                if (end - lineStart < wrapLength) {
                    sb.append(string.substring(start, end));
                } else {
                    // wrap
                    if (true || end - start < wrapLength) {
                        sb.append(lineSeparator);
                        sb.append(string.substring(start, end));
                    } else {
                        // TODO
                        // truncate
                    }
                    lineStart = end;
                }
            }
            string = sb.toString();
        }

        return string;
    }

    /**
     * Check to see if the string has no value
     *
     * @param String the string
     *
     * @return boolean (true meaning no value)
     */
    private static boolean isBlank(String string) {
        return (string == null || string.trim().equals(""));
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBoxMenuItem AdrrBookAllCheckBox;
    private javax.swing.JFileChooser IpdChooser;
    private javax.swing.JFrame MessageFrame;
    private javax.swing.JCheckBoxMenuItem ResolveCheckBox;
    private javax.swing.JCheckBoxMenuItem TollTipsBoxMenuItem;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JFileChooser jFileChooser1;
    private javax.swing.JMenu jMenuCP;
    private javax.swing.JMenu jMenuHelp;
    private javax.swing.JMenu jMenuHistory;
    private javax.swing.JMenuItem jMenuItemAbout;
    private javax.swing.JMenuItem jMenuItemCPCSV;
    private javax.swing.JMenuItem jMenuItemCPTXT;
    private javax.swing.JMenuItem jMenuItemCPXML;
    private javax.swing.JMenuItem jMenuItemCSV;
    private javax.swing.JMenuItem jMenuItemSelectedCallLogsCSV;
    private javax.swing.JMenuItem jMenuItemSelectedCallLogsText;
    private javax.swing.JMenuItem jMenuItemSelectedCallLogsXML;
    private javax.swing.JMenuItem jMenuItemSelectedSMSCSV;
    private javax.swing.JMenuItem jMenuItemSelectedSMSTxt;
    private javax.swing.JMenuItem jMenuItemSelectedSMSXML;
    private javax.swing.JMenuItem jMenuItemTxt;
    private javax.swing.JMenuItem jMenuItemViewHistoryTXT;
    private javax.swing.JMenuItem jMenuItemViewHistoryXML;
    private javax.swing.JMenuItem jMenuItemXML;
    private javax.swing.JMenu jMenuSettings;
    private javax.swing.JMenu jMenuSpCallLogs;
    private javax.swing.JMenu jMenuSpSMS;
    private javax.swing.JPanel jPanelCalendar;
    private javax.swing.JPanel jPanelCallLogs;
    private javax.swing.JPanel jPanelContacts;
    private javax.swing.JPanel jPanelMemo;
    private javax.swing.JPanel jPanelOptions;
    private javax.swing.JPanel jPanelSMS;
    private javax.swing.JPanel jPanelTasks;
    private javax.swing.JPopupMenu jPopupMenu;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JSeparator jSeparator;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTable jTableCallLogs;
    private javax.swing.JTable jTableContacts;
    private javax.swing.JTable jTableMemos;
    private javax.swing.JTable jTableSMS;
    private javax.swing.JTable jTableTasks;
    private javax.swing.JTabbedPane mainTabbedPane;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem openMenuItem;
    private javax.swing.JMenuItem saveAsMenuItem;
    private javax.swing.JLabel status_label;
    private javax.swing.JLabel status_label6;
    private javax.swing.JLabel status_label7;
    // End of variables declaration//GEN-END:variables
}


 class SMSRenderer extends DefaultTableCellRenderer {

    private boolean wasSent=false;

     public void setWasSent(boolean wasSent){
     this.wasSent=wasSent;
     }

  /*
   * @see TableCellRenderer#getTableCellRendererComponent(JTable, Object, boolean, boolean, int, int)
   */
  public Component getTableCellRendererComponent(JTable table, Object value,
                                                 boolean isSelected, boolean hasFocus,
                                                 int row, int column) {
                                                 ImageIcon icon;
    if (wasSent) {
        icon = new ImageIcon(getClass().getResource("/gui/resources/receive.png"));
        } else
        {
       icon = new ImageIcon(getClass().getResource("/gui/resources/sent.png"));
        }
    setText((String)value);
    setIcon(icon);
    return this;
  }
}
